package dev.bong.controller;

import dev.bong.pojo.result.Result;
import dev.bong.service.ExperimentService;
import dev.bong.utils.ThreadLocalUtil;
import dev.bong.vo.RepairVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author: bong~
 * @description: TODO
 * @date: 2024/4/14 11:20
 * @version: 1.0
 */

@RestController
@Slf4j
@RequestMapping("/experiment")
@Api(tags = "实验员模块")
public class ExperimentController {

    @Autowired
    private ExperimentService experimentService;

    @ApiOperation(value = "获取报修列表",notes="报修状态：-1:未维修,0:维修中,1:已维修")
    @GetMapping("/repair/list")
    public Result<List<RepairVo>> gerRepairList(){

        Map<String,Object> map= ThreadLocalUtil.get();
        Integer userId= (Integer) map.get("userId");

        List<RepairVo> ans=experimentService.getRepairList(userId);

        return Result.success(ans);
    }

    @ApiOperation("更改维修状态——开始维修")
    @PostMapping("/repair/start")
    public Result startRepair(Integer repairId){

        experimentService.startRepair(repairId);

        return Result.success("开始维修");

    }

    @ApiOperation("更改维修状态——完成维修")
    @PostMapping("/repair/finish")
    public Result finishRepair(Integer repairId,String situation) {

        experimentService.finishRepair(repairId, situation);

        return Result.success("完成维修");

    }



}
